#pragma once

#include <list>
#include <set>
#include <map>
#include <vector>
#include <string>
#include "Enum.h"

class Item;

struct ItemStackItem {
	Item* item;
	bool visible;
	bool selected;
	bool filtered;
	int stackChange;
};

class ItemStack {
protected:
	int m_filter;
	std::string m_title;
	std::vector<ItemStackItem*>* m_items;
	int m_currentItem;
	int m_height;
	int getNumDrawableItems() const;
	int getMaxLastIndex() const;
public:
	static std::map<GenericType, FilterType> filterMap;
	static std::map<GenericType, TypeHierarchy> typeHierarchyMap;
	static char filterChars[];
	static void initGameData();
	ItemStack(std::list<Item*>* items, std::string title, int height);
	~ItemStack();
	std::vector<ItemStackItem*>* getItems() const;
	int convertMod(int mod, bool checkBounds = true) const;
	int getCurrentItem() const;
	Item* getItem(int mod) const;
	void resetCurrentIndex();
	void shift(bool up);
	void page(bool up);
	void selectItem(int mod);
	std::vector<Item*>* getSelectedItems() const;
	void setTitle(std::string title);
	std::string getTitle() const;
	void setFilter(int filter, bool force = true);
	void showOnly(TypeHierarchy typeCategory, int type);
	void show(TypeHierarchy typeCategory, int type);
	void setVisible(Item* item, bool visible);
	int getFilter() const;
	void stackChange(Item* item, int i);
};

inline std::vector<ItemStackItem*>* ItemStack::getItems() const {return m_items;}
inline void ItemStack::resetCurrentIndex() {m_currentItem = 0;}
inline void ItemStack::setTitle(std::string title) {m_title = title;}
inline std::string ItemStack::getTitle() const {return m_title;}
inline int ItemStack::getCurrentItem() const {return m_currentItem;}
inline int ItemStack::getFilter() const {return m_filter;}
